<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Excel预览</title>
  <!--xlsx: https://github.com/SheetJS/sheetjs-->
  <script src="https://cdn.bootcdn.net/ajax/libs/xlsx/0.16.8/xlsx.full.min.js"></script>
</head>
<body>
  <ul id="sheets">
  </ul>
  <iframe id="content" width="100%" height="100%"></iframe>
  <script>
    const sheets = document.querySelector('#sheets')
    const iframe = document.querySelector('#content')
    var url = "/a.xlsx";

    /* set up async GET request */
    var req = new XMLHttpRequest();
    req.open("GET", url, true);
    req.responseType = "arraybuffer";

    var workbook = null;
    var data = null;
    req.onload = function(e) {
      data = new Uint8Array(req.response);
      workbook = XLSX.read(data, {type:"array"});

      /* DO SOMETHING WITH workbook HERE */
      const fg = document.createDocumentFragment();
      Object.keys(workbook.Sheets).forEach(sheetName => {
        const li = document.createElement('li')
        li.innerText = sheetName
        fg.appendChild(li)
      })
      sheets.appendChild(fg)
    }
    var html = ''
    sheets.addEventListener('click', ({ target }) => {
      console.log(target.innerText)
      html = XLSX.utils.sheet_to_html(workbook.Sheets[target.innerText])
      iframe.contentDocument.write(html)
    })
    req.send();
  </script>
</body>
</html>